package com.hnkywl.sts.entity.jhgl;

import com.hnkywl.sts.entity.BaseEntity;
import com.hnkywl.sts.entity.base.Fj;
import com.hnkywl.sts.entity.base.Sjzdz;
import com.hnkywl.sts.entity.organ.*;
import com.hnkywl.sts.entity.sys.Yg;
import org.hibernate.annotations.Formula;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;
import org.hibernate.annotations.Where;


import javax.persistence.*;

import java.util.Date;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

/**
 * 说明：协议
 * 包:        com.hnkywl.sts.entity.jhgl
 * 类描述:    协议
 * 修改备注: [说明本次修改内容]
 * 版本:        [v1.0]
 */
@Entity
@Table(name = "T_BIZ_XY")
@Where(clause = "deleted!='1'")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "TYPE", discriminatorType = DiscriminatorType.STRING)
@DiscriminatorValue("xy")
public class Xy extends BaseEntity {
    @Id
    @SequenceGenerator(name = "seqXy", allocationSize = 1, sequenceName = "SEQ_BIZ_XY")
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "seqXy")
    private Long id;

    /**
     * 协议号码
     */
    private String xyhm;

    /**
     * 经营模式
     */
    @OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL, targetEntity = Jyms.class)
    @JoinColumn(name = "JYMS_ID")
    private Jyms jyms;

    /**
     * 路径
     */
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name="LJ_ID")
    private Lj lj;

    /**
     * 内部公司
     */
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name="NBGS_ID")
    private Gsjg nbgs;

    /**
     * 年协议量
     */
    private Integer nxyl;

    /**
     * 月协议量
     */
    private Integer yxyl;

    /**
     * 协议量单位
     */
    private String yxldw;

    /**
     * 主要产品
     */
    private String zycp;

    /**
     * 付款方式
     */
    @ManyToOne
    @JoinColumn(name="SJZDZ_FKFS_ID")
    private Sjzdz fkfs;

    /**
     * 交货方式
     */
    private String jhfs;

    /**
     * 开始时间
     */
    private Date kssj;

    /**
     * 结束时间
     */
    private Date jssj;

    /**
     * 制单人
     */
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name="ZDR_ID")
    @NotFound(action= NotFoundAction.IGNORE)
    private Yg zdr;

    /**
     * 制单时间
     */
    private Date zdsj;

    /**
     * 履约人
     */
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name="LYR_ID")
    @NotFound(action= NotFoundAction.IGNORE)
    private Yg lyr;

    /**
     * 履约时间
     */
    private Date lysj;

    /**
     * 是否履约
     */
    private Boolean sfly;

    /**
     * 终止人
     */
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name="ZZR_ID")
    @NotFound(action= NotFoundAction.IGNORE)
    private Yg zzr;

    /**
     * 终止日期
     */
    private Date zzsj;

    /**
     * 终止原因
     */
    private String zzyy;

    /**
     * 是否强制终止
     */
    private Boolean sfqzzz;

    /**
     * 担保方
     */
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name="DBF_ID")
    @NotFound(action= NotFoundAction.IGNORE)
    private Qyjg dbf;

    /**
     * 担保方式
     */
    private String dbfs;

    /**
     * 担保额
     */
    private Double dbe;




    /**
     * 备注
     */
    private String bz;

    /**
     * 关联流程
     */
    @Basic
    @Column(name="LC_ID")
    private String processInstanceId;

    /**
     * 协议附件
     */
    @OneToMany(cascade = CascadeType.MERGE,fetch = FetchType.LAZY,targetEntity = Fj.class)
    @JoinColumn(name = "XY_ID")
    private List<Fj> fjList;


    /**
     * 协议状态（已保存，已提交，已审批）
     */
    private String xyzt;

    /**
     * 融资类型
     */
    private RZLX rzlx;

    public RZLX getRzlx() {
        return rzlx;
    }

    public void setRzlx(RZLX rzlx) {
        this.rzlx = rzlx;
    }

    public enum RZLX {
        //0、代订货 1、商贸银 2、保兑仓
        DDH("代订货"), SMY("商贸银"), BDC("保兑仓");

        private RZLX(String mc) {
            this.mc = mc;
        }

        private String mc;

        public String getMc() {
            return mc;
        }

        public static Map<String, String> getRzlxList() {
            Map<String, String> map = new LinkedHashMap<String, String>();
            RZLX[] temp = RZLX.values();
            for (int i = 0; i < temp.length; i++)
                map.put(temp[i].toString(), temp[i].getMc());
            return map;
        }
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getXyhm() {
        return xyhm;
    }

    public void setXyhm(String xyhm) {
        this.xyhm = xyhm;
    }

    public Jyms getJyms() {
        return jyms;
    }

    public void setJyms(Jyms jyms) {
        this.jyms = jyms;
    }

    public Lj getLj() {
        return lj;
    }

    public void setLj(Lj lj) {
        this.lj = lj;
    }

    public Gsjg getNbgs() {
        return nbgs;
    }

    public void setNbgs(Gsjg nbgs) {
        this.nbgs = nbgs;
    }

    public Integer getNxyl() {
        return nxyl;
    }

    public void setNxyl(Integer nxyl) {
        this.nxyl = nxyl;
    }

    public Integer getYxyl() {
        return yxyl;
    }

    public void setYxyl(Integer yxyl) {
        this.yxyl = yxyl;
    }

    public String getYxldw() {
        return yxldw;
    }

    public void setYxldw(String yxldw) {
        this.yxldw = yxldw;
    }

    public Sjzdz getFkfs() {
        return fkfs;
    }

    public void setFkfs(Sjzdz fkfs) {
        this.fkfs = fkfs;
    }

    public String getJhfs() {
        return jhfs;
    }

    public void setJhfs(String jhfs) {
        this.jhfs = jhfs;
    }

    public Date getKssj() {
        return kssj;
    }

    public void setKssj(Date kssj) {
        this.kssj = kssj;
    }

    public Date getJssj() {
        return jssj;
    }

    public void setJssj(Date jssj) {
        this.jssj = jssj;
    }

    public Yg getZdr() {
        return zdr;
    }

    public void setZdr(Yg zdr) {
        this.zdr = zdr;
    }

    public Date getZdsj() {
        return zdsj;
    }

    public void setZdsj(Date zdsj) {
        this.zdsj = zdsj;
    }

    public Yg getLyr() {
        return lyr;
    }

    public void setLyr(Yg lyr) {
        this.lyr = lyr;
    }

    public Date getLysj() {
        return lysj;
    }

    public void setLysj(Date lysj) {
        this.lysj = lysj;
    }

    public Boolean getSfly() {
        return sfly;
    }

    public void setSfly(Boolean sfly) {
        this.sfly = sfly;
    }

    public Yg getZzr() {
        return zzr;
    }

    public void setZzr(Yg zzr) {
        this.zzr = zzr;
    }

    public Date getZzsj() {
        return zzsj;
    }

    public void setZzsj(Date zzsj) {
        this.zzsj = zzsj;
    }

    public String getZzyy() {
        return zzyy;
    }

    public void setZzyy(String zzyy) {
        this.zzyy = zzyy;
    }

    public Boolean getSfqzzz() {
        return sfqzzz;
    }

    public void setSfqzzz(Boolean sfqzzz) {
        this.sfqzzz = sfqzzz;
    }

    public Qyjg getDbf() {
        return dbf;
    }

    public void setDbf(Qyjg dbf) {
        this.dbf = dbf;
    }

    public String getDbfs() {
        return dbfs;
    }

    public void setDbfs(String dbfs) {
        this.dbfs = dbfs;
    }

    public Double getDbe() {
        return dbe;
    }

    public void setDbe(Double dbe) {
        this.dbe = dbe;
    }

    public String getBz() {
        return bz;
    }

    public void setBz(String bz) {
        this.bz = bz;
    }

    public String getProcessInstanceId() {
        return processInstanceId;
    }

    public void setProcessInstanceId(String processInstanceId) {
        this.processInstanceId = processInstanceId;
    }

    public List<Fj> getFjList() {
        return fjList;
    }

    public void setFjList(List<Fj> fjList) {
        this.fjList = fjList;
    }

    public String getZycp() {
        return zycp;
    }

    public void setZycp(String zycp) {
        this.zycp = zycp;
    }

    public String getXyzt() {
        return xyzt;
    }

    public void setXyzt(String xyzt) {
        this.xyzt = xyzt;
    }

}
